package com.example.openfeign.service;

import com.example.common.api.CommonResult;
import com.example.openfeign.dto.UserDto;
import org.springframework.stereotype.Component;

@Component
public class UserFallbackService implements UserService {
    @Override
    public CommonResult create(UserDto user) {
        UserDto defaultUser = new UserDto("defaultUser", "123456");
        return CommonResult.success(defaultUser);
    }

    @Override
    public CommonResult<UserDto> getUser(Long id) {
        UserDto defaultUser = new UserDto("defaultUser", "123456");
        return CommonResult.success(defaultUser);
    }

    @Override
    public CommonResult<UserDto> getByUsername(String username) {
        UserDto defaultUser = new UserDto("defaultUser", "123456");
        return CommonResult.success(defaultUser);
    }

    @Override
    public CommonResult update(UserDto user) {
        return CommonResult.failed("调用失败，服务被降级");
    }

    @Override
    public CommonResult delete(Long id) {
        return CommonResult.failed("调用失败，服务被降级");
    }
}
